<template>
  <div>
    <el-card class="mb">
      <div class="title mb">任务列表</div>
      <el-form :inline="true" label-width="100px" :model="form">
        <el-form-item label="会议名称：">
          <el-input
            v-model="form.meetingName"
            clearable
            placeholder="请输入"
          ></el-input>
        </el-form-item>
        <el-form-item label="会议时间：">
          <el-date-picker
            v-model="form.meetingTime"
            placeholder="选择日期"
            value-format="yyyy-MM-dd"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="search">查询</el-button>
        </el-form-item>
        <el-form-item>
          <el-button @click="reset">重置</el-button>
        </el-form-item>
      </el-form>
    </el-card>
    <el-card>
      <taskTable
        :tableData="tableData"
        :tabtitle="tabtitle"
        :loading="loading"
        height="calc(100vh - 270px)"
        :current="pageNum"
        :pageSize="pageSize"
        :total="total"
        @handleSizeChange="handleSizeChange"
        @handleCurrentChange="handleCurrentChange"
        sortProp="meetingTime"
      >
        <el-table-column align="center" label="操作">
          <template slot-scope="scope">
            <el-button type="text" @click="dlalogOpen(scope.row)"
              >查看</el-button
            >
          </template>
        </el-table-column>
      </taskTable>
    </el-card>
    <DialogTable ref="DialogTable"></DialogTable>
  </div>
</template>

<script>
import taskTable from '@/components/Table.vue'
import DialogTable from './components/DialogTable.vue'
import { findMeetingByGenerate } from '@/apis/meetingList.js'
export default {
  components: {
    taskTable,
    DialogTable
  },
  data() {
    return {
      form: {
        meetingName: '',
        meetingTime: ''
      },
      codeList: [],
      tableData: [],
      loading: false,
      pageNum: 1,
      pageSize: 10,
      total: 0,
      tabtitle: [
        { prop: 'meetingName', label: '会议名称', align: 'center' },
        { prop: 'typeDesc', label: '会议类型', align: 'center' },
        { prop: 'masterUserName', label: '会议负责人', align: 'center' },
        {
          prop: 'meetingTime',
          label: '会议时间',
          align: 'center',
          sortable: true
        },
        {
          prop: 'generateState',
          label: '状态',
          render: (h, scope) => {
            return h(
              'div',
              {
                attrs: {
                  class: scope.row.generateState
                    ? scope.row.generateState === '0'
                      ? 'type-normal'
                      : 'type-warning'
                    : ''
                }
              },
              scope.row.generateStateDesc
            )
          }
        }
      ]
    }
  },
  mounted() {
    this.getTableData()
  },
  methods: {
    getTableData() {
      this.loading = true
      const { pageNum, pageSize } = this
      findMeetingByGenerate({ ...this.form, pageNum, pageSize })
        .then((res) => {
          if (res.code === 200) {
            this.tableData = res.data.list
            this.total = res.data.total
          }
          this.loading = false
        })
        .catch(() => {
          this.loading = false
        })
    },
    search() {
      this.pageNum = 1
      this.getTableData()
    },
    reset() {
      this.form = this.$options.data().form
      this.search()
    },
    dlalogOpen(row) {
      this.$refs.DialogTable.show(row)
    },
    handleSizeChange(val) {
      this.pageSize = val
      this.getTableData()
    },
    handleCurrentChange(val) {
      this.pageNum = val
      this.getTableData()
    }
  }
}
</script>

<style lang="less" scoped>
.title {
  font-size: 20px;
  font-weight: bold;
}
.mb {
  margin-bottom: 15px;
}
</style>
